/**
 * 
 */
package com.manage.action;

import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;


import com.action.AbstractAction;
import com.manage.cache.SdkProvidersManager;
import com.manage.model.SdkProviders;
import com.util.Util;


public class SdkProvidersAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Logger logger;
	
	public SdkProvidersAction()
	{
		logger = Logger.getLogger(this.getClass());
	}
	
	public String execute()
	{
		return SUCCESS;
	}

	private List<SdkProviders> list;
	private SdkProviders       model;
	private String        type;
	
	public String list()
	{
		logger.debug("list SdkProviders");
		list = SdkProvidersManager.getInstance().getSdkProviders();
		return SUCCESS;
	}
	
	public String show()
	{
		if (model.getId() >= 0)
		{
			model = SdkProvidersManager.getInstance().getSdkProviders(model.getId());
			type = "update";
		}
		else
		{
			model.setAccessdate(Util.dateToString(new Date(),"yyyy-MM-dd"));
			model.setId(-1);
			type = "insert";
		}

		return SUCCESS;
	}
	
	public String save()
	{
		if(type.equals("insert"))
		{
			model.setCreatedate(Util.dateToString(new Date()));
			model.setCreateuser(operator.getName());
		}
		SdkProvidersManager.getInstance().saveSdkProviders(operator, type, model);
		return SUCCESS;
	}

	public List<SdkProviders> getList() {
		return list;
	}

	public void setList(List<SdkProviders> list) {
		this.list = list;
	}

	public SdkProviders getModel() {
		return model;
	}

	public void setModel(SdkProviders model) {
		this.model = model;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	
	
}
